package org.come.Jpanel;

import com.tool.btn.FaHuoBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
import org.come.until.FormsManagement;

import javax.swing.*;
import java.awt.*;
import java.math.BigDecimal;

public class FaHuoJpanel extends JPanel {

    private FaHuoBtn codeBtn1,// 确定按钮
            codeBtn2;// 取消按钮
    private JTextField textCode;// 输入兑奖码
    private JLabel titleJLabel;

    public FaHuoJpanel() {
        if("水墨UI".equals(MyIsif.getStyle())) {
            this.setPreferredSize(new Dimension(534, 145));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);

            // 输入兑换码
            textCode = new JTextField();
            textCode.setBounds(28, 88, 475, 15);
            textCode.setFont(UIUtils.TEXT_FONT1);
            textCode.setOpaque(false);
            textCode.setBorder(BorderFactory.createEmptyBorder());
            textCode.setCaretColor(Color.white);
            textCode.setForeground(Color.white);
            this.add(textCode);

            // 确定按钮
            codeBtn1 = new FaHuoBtn("skin/8100226/button/B59.png", 1, "发 货", this,null);
            codeBtn1.setBounds(150, 112, 68, 26);
            this.add(codeBtn1);
            // 取消按钮
            codeBtn2 = new FaHuoBtn("skin/8100226/button/B59.png", 1, "取 消", this,null);
            codeBtn2.setBounds(300, 112, 68, 26);
            this.add(codeBtn2);
            // 标题
            titleJLabel = new JLabel();
            titleJLabel.setForeground(Color.YELLOW);
            titleJLabel.setFont(UIUtils.TEXT_FONT);
            titleJLabel.setVerticalTextPosition(SwingConstants.CENTER);
            titleJLabel.setBounds(200, 10, 134, 20);
            this.add(titleJLabel);
            xz2 = "进行发货，请输入玩家ID";
        }else {
            this.setPreferredSize(new Dimension(534, 145));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);

            // 输入兑换码
            textCode = new JTextField();
            textCode.setBounds(40, 70, 475, 15);
            textCode.setFont(UIUtils.TEXT_FONT1);
            textCode.setOpaque(false);
            textCode.setBorder(BorderFactory.createEmptyBorder());
            textCode.setCaretColor(Color.white);
            textCode.setForeground(Color.white);
            this.add(textCode);

            // 确定按钮
            codeBtn1 = new FaHuoBtn("inkImg/hongmu/1/60_26.png", 1, "发 货", this);
            codeBtn1.setBounds(120, 90, 60, 26);
            this.add(codeBtn1);
            // 取消按钮
            codeBtn2 = new FaHuoBtn("inkImg/hongmu/1/60_26.png", 1, "取 消", this);
            codeBtn2.setBounds(270, 90, 60, 26);
            this.add(codeBtn2);
            // 标题
            titleJLabel = new JLabel();
            titleJLabel.setForeground(Color.YELLOW);
            titleJLabel.setFont(UIUtils.TEXT_FONT);
            titleJLabel.setVerticalTextPosition(SwingConstants.CENTER);
            titleJLabel.setBounds(200, 10, 134, 20);
            this.add(titleJLabel);
            xz2 = "进行发货，请输入玩家ID";
        }
    }

    private int type;// 0改名卡1修正卡2兑换 3解禁4解封
    private BigDecimal rgid;

    /** 更改使用类型 */
    public void use(int type, BigDecimal rgid) {
        this.type = type;
        this.rgid = rgid;
        xz3 = null;
        xz2 = "进行发货，请输入要玩家ID";

        FormsManagement.showForm(559);
    }

    String xz2 = "";
    String xz3 = "";
    private ImageIcon icon;
    @Override
    protected void paintComponent(Graphics g) {
//    	//system.out.println(g);
        super.paintComponent(g);
        if("水墨UI".equals(MyIsif.getStyle())) {
            if (icon == null) {
                icon = new ImageIcon("inkImg/newbackground/B235.png");
            }
            // 背景
            g.drawImage(icon.getImage(), 0, 0, 534, 145, this);
            if (xz2 != null) {
                g.setFont(UIUtils.TEXT_FONT);
                g.setColor(Color.WHITE);
                g.drawString(xz2, 24, 45);
                if (xz3 != null) {
                    g.drawString(xz3, 24, 65);
                }
            }
        }else {
            if (icon == null) {
                icon = new ImageIcon("inkImg/number/b8/单行输入框.png");
            }
            // 背景
            g.drawImage(icon.getImage(), 0, 0, 430, 130, this);
            if (xz2 != null) {
                g.setFont(UIUtils.TEXT_FONT);
                g.setColor(Color.WHITE);
                g.drawString(xz2, 40, 45);
                if (xz3 != null) {
                    g.drawString(xz3, 24, 65);
                }
            }
        }
    }

    public JTextField getTextCode() {
        return textCode;
    }

    public void setTextCode(JTextField textCode) {
        this.textCode = textCode;
    }

    public BigDecimal getRgid() {
        return rgid;
    }

    public void setRgid(BigDecimal rgid) {
        this.rgid = rgid;
    }

}
